<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--引入vue和axios-->
    <script src="js/plugins/vue/dist/vue.js"></script>
    <script src="js/plugins/axios/dist/axios.js"></script>
    <!--全局配置axios-->
    <script src="js/common.js"></script>
</head>
<body>
   <div id="myDiv">

   </div>
   <script type="text/javascript">
       new Vue({
           el:"#myDiv",
           data:{

           },
           methods:{
           },
           mounted(){
               //页面加载完毕立即发请求
               let code = parseUrlParams2Obj(location.href).code;//从请求地址解析
               let binderUrl = 'http://bugtracker.itsource.cn/binder.html';
               let params = {code:code,binderUrl:binderUrl}

               this.$http.post("/login/weixin",params)
                   .then(result=>{
                       //1 登录成功
                       result = result.data;
                       if(result.success){
                           let {token, user} = result.resultObj;
                           localStorage.setItem('uToken', token);
                           localStorage.setItem('uUser', JSON.stringify(user));
                           //跳转到主页
                           location.href = "/index.html"
                       }
                       //2 跳转绑定页面
                       if(!result.success&&result.message==="binder"){
                          let binderUrl =  result.resultObj; //有两个参数ack,openid
                          location.href = binderUrl;
                       }
                   })
                   .catch(result=>{
                       console.log(result)
                   })
           }
       })
   </script>
</body>
</html>